package tosp.job;


public class SimpleJob extends JobAdapter implements Comparable<SimpleJob> {

	int[] tools; // sortiert !!
	int toolcount;
	
	/**
	 * Create Job, ensures, tools-array is sorted;
	 * @param id
	 * @param tools
	 */
	public SimpleJob(int id,int[] tools) {
		this.id=this.index=id;
		java.util.Arrays.sort(tools);
		this.tools=tools;
		toolcount=tools.length;
	}

	/**
	 * Copy Constructor
	 * @param j
	 */
	public SimpleJob(Job j) {
		this.id=j.getID();
		this.index=j.getIndex();
		this.tools=j.getTools().clone();
		java.util.Arrays.sort(tools);
		toolcount=tools.length;
	}
	
	/**
	 * Info: how many tools do this job use?
	 */
	public int getNumberOfTools() {
		return toolcount;
	}

	/**
	 * Which tools does this job use?
	 */
	public int[] getTools() {
		return tools;
	}	

	/*
	 * Compare by job-id
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(SimpleJob other) {
		int v=0;
		if (this.index<other.getIndex())
			v = -1;
		else if (this.index>other.getIndex())
			v = 1;
		return v;
	}
	/*
	public boolean equals(Object other) {
		if (!(other instanceof SimpleJob)) return false;
		return equals((SimpleJob)other);
	}
	
	public int hashCode() {
		long[] t = {id};
		return Arrays.hashCode(t);
	}
	*/
}
